####
#### Note: THIS FILE CONTAINS Replication Code for MEDIATION MODELS USED FOR EFS, PoP 2018
####
#### Last Update - 9/13/2018


## Step 1 - Install Packages and Load Data

##install.packages("mediation")
library(mediation)
update.packages("mediation")


library(foreign)
library(mediation)

clevel <- .95


ac_data <- read.dta("~PoP_MediationFile.dta")


## Step 2 - Make and Check Factor Vars

ac_data$white.f <- factor(ac_data$white_f)

is.factor(ac_data$white.f)


ac_data$gender.f <- factor(ac_data$gender_f)

is.factor(ac_data$gender.f)


ac_data$back_down_prez.f <- factor(ac_data$back_down_prez)

is.factor(ac_data$back_down_prez.f)


ac_data$back_down_obama.f <- factor(ac_data$back_down_obama)

is.factor(ac_data$back_down_obama.f)


ac_data$back_down_trump.f <- factor(ac_data$back_down_trump)

is.factor(ac_data$back_down_trump.f)



ac_data$prejust.f <- factor(ac_data$prejust1)

is.factor(ac_data$prejust.f)


ac_data$obajust.f <- factor(ac_data$obajust1)

is.factor(ac_data$obajust.f)


ac_data$trujust.f <- factor(ac_data$trujust1)

is.factor(ac_data$trujust.f)



#################
################
################
#################


## Step 3 - Moderated Mediation Models (by partisanship of respondent) for Back Down Treatment


## Moderated MEDIATION - Morals PREZ

model.m1 <- lm(morals_n ~ back_down_prez.f * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


model.y1 <- lm(approve_n ~ back_down_prez.f * party + morals_n * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


prezmorals_dem <- mediate (model.m1, model.y1,
                           treat = "back_down_prez.f", mediator = "morals_n", covariates = list(party = "Democrat"),
                           sims= 1000, boot = TRUE)


prezmorals_rep <- mediate (model.m1, model.y1,
                           treat = "back_down_prez.f", mediator = "morals_n", covariates = list(party = "Republican"),
                           sims= 1000, boot = TRUE)

summary(prezmorals_dem)
summary(prezmorals_rep)



## Moderated MEDIATION - Morals Obama


model.m2 <- lm(morals_n ~ back_down_obama.f * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


model.y2 <- lm(approve_n ~ back_down_obama.f * party + morals_n * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


obamorals_dem <- mediate (model.m2, model.y2,
                          treat = "back_down_obama.f", mediator = "morals_n", covariates = list(party = "Democrat"),
                          sims= 1000, boot = TRUE)


obamorals_rep <- mediate (model.m2, model.y2,
                          treat = "back_down_obama.f", mediator = "morals_n", covariates = list(party = "Republican"),
                          sims= 1000, boot = TRUE)

summary(obamorals_dem)
summary(obamorals_rep)




## Moderated MEDIATION - Morals Trump


model.m3 <- lm(morals_n ~ back_down_trump.f * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


model.y3 <- lm(approve_n ~ back_down_trump.f * party + morals_n * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


trumorals_dem <- mediate (model.m3, model.y3,
                          treat = "back_down_trump.f", mediator = "morals_n", covariates = list(party = "Democrat"),
                          sims= 1000, boot = TRUE)


trumorals_rep <- mediate (model.m3, model.y3,
                          treat = "back_down_trump.f", mediator = "morals_n", covariates = list(party = "Republican"),
                          sims= 1000, boot = TRUE)

summary(trumorals_dem)
summary(trumorals_rep)



## Moderated MEDIATION - Commitment PREZ

model.m4 <- lm(commit_n ~ back_down_prez.f * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


model.y4 <- lm(approve_n ~ back_down_prez.f * party + commit_n * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


prezcommit_dem <- mediate (model.m4, model.y4,
                           treat = "back_down_prez.f", mediator = "commit_n", covariates = list(party = "Democrat"),
                           sims= 1000, boot = TRUE)


prezcommit_rep <- mediate (model.m4, model.y4,
                           treat = "back_down_prez.f", mediator = "commit_n", covariates = list(party = "Republican"),
                           sims= 1000, boot = TRUE)

summary(prezcommit_dem)
summary(prezcommit_rep)



## Moderated MEDIATION - Commitment Obama


model.m5 <- lm(commit_n ~ back_down_obama.f * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


model.y5 <- lm(approve_n ~ back_down_obama.f * party + commit_n * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)



obacommit_dem <- mediate (model.m5, model.y5,
                          treat = "back_down_obama.f", mediator = "commit_n", covariates = list(party = "Democrat"),
                          sims= 1000, boot = TRUE)


obacommit_rep <- mediate (model.m5, model.y5,
                          treat = "back_down_obama.f", mediator = "commit_n", covariates = list(party = "Republican"),
                          sims= 1000, boot = TRUE)

summary(obacommit_dem)
summary(obacommit_rep)


## Moderated MEDIATION - Commitment Trump


model.m6 <- lm(commit_n ~ back_down_trump.f * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


model.y6 <- lm(approve_n ~ back_down_trump.f * party + commit_n * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


trucommit_dem <- mediate (model.m6, model.y6,
                          treat = "back_down_trump.f", mediator = "commit_n", covariates = list(party = "Democrat"),
                          sims= 1000, boot = TRUE)


trucommit_rep <- mediate (model.m6, model.y6,
                          treat = "back_down_trump.f", mediator = "commit_n", covariates = list(party = "Republican"),
                          sims= 1000, boot = TRUE)

summary(trucommit_dem)
summary(trucommit_rep)



## Moderated MEDIATION - Comp PREZ

model.m13 <- lm(comp_n ~ back_down_prez.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y13 <- lm(approve_n ~ back_down_prez.f * party + comp_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


prezcomp_dem <- mediate (model.m13, model.y13,
                         treat = "back_down_prez.f", mediator = "comp_n", covariates = list(party = "Democrat"),
                         sims= 1000, boot = TRUE)


prezcomp_rep <- mediate (model.m13, model.y13,
                         treat = "back_down_prez.f", mediator = "comp_n", covariates = list(party = "Republican"),
                         sims= 1000, boot = TRUE)

summary(prezcomp_dem)
summary(prezcomp_rep)



## Moderated MEDIATION - Comp Obama


model.m14 <- lm(comp_n ~ back_down_obama.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y14 <- lm(approve_n ~ back_down_obama.f * party + comp_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


obacomp_dem <- mediate (model.m14, model.y14,
                        treat = "back_down_obama.f", mediator = "comp_n", covariates = list(party = "Democrat"),
                        sims= 1000, boot = TRUE)


obacomp_rep <- mediate (model.m14, model.y14,
                        treat = "back_down_obama.f", mediator = "comp_n", covariates = list(party = "Republican"),
                        sims= 1000, boot = TRUE)

summary(obacomp_dem)
summary(obacomp_rep)


## Moderated MEDIATION - Comp Trump


model.m15 <- lm(comp_n ~ back_down_trump.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y15 <- lm(approve_n ~ back_down_trump.f * party + comp_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


trucomp_dem <- mediate (model.m15, model.y15,
                        treat = "back_down_trump.f", mediator = "comp_n", covariates = list(party = "Democrat"),
                        sims= 1000, boot = TRUE)


trucomp_rep <- mediate (model.m15, model.y15,
                        treat = "back_down_trump.f", mediator = "comp_n", covariates = list(party = "Republican"),
                        sims= 1000, boot = TRUE)

summary(trucomp_dem)
summary(trucomp_rep)


## Moderated MEDIATION - Reputation PREZ

model.m16 <- lm(reputation_n ~ back_down_prez.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y16 <- lm(approve_n ~ back_down_prez.f * party + reputation_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)

prezrep_dem <- mediate (model.m16, model.y16,
                        treat = "back_down_prez.f", mediator = "reputation_n", covariates = list(party = "Democrat"),
                        sims= 1000, boot = TRUE)


prezrep_rep <- mediate (model.m16, model.y16,
                        treat = "back_down_prez.f", mediator = "reputation_n", covariates = list(party = "Republican"),
                        sims= 1000, boot = TRUE)

summary(prezrep_dem)
summary(prezrep_rep)


## Moderated MEDIATION - Reputation Obama


model.m17 <- lm(reputation_n ~ back_down_obama.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y17 <- lm(approve_n ~ back_down_obama.f * party + reputation_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)

obarep_dem <- mediate (model.m17, model.y17,
                       treat = "back_down_obama.f", mediator = "reputation_n", covariates = list(party = "Democrat"),
                       sims= 1000, boot = TRUE)


obarep_rep <- mediate (model.m17, model.y17,
                       treat = "back_down_obama.f", mediator = "reputation_n", covariates = list(party = "Republican"),
                       sims= 1000, boot = TRUE)

summary(obarep_dem)
summary(obarep_rep)



## Moderated MEDIATION - Reputation Trump


model.m18 <- lm(reputation_n ~ back_down_trump.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y18 <- lm(approve_n ~ back_down_trump.f * party + reputation_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


trurep_dem <- mediate (model.m18, model.y18,
                       treat = "back_down_trump.f", mediator = "reputation_n", covariates = list(party = "Democrat"),
                       sims= 1000, boot = TRUE)


trurep_rep <- mediate (model.m18, model.y18,
                       treat = "back_down_trump.f", mediator = "reputation_n", covariates = list(party = "Republican"),
                       sims= 1000, boot = TRUE)

summary(trurep_dem)
summary(trurep_rep)




###############################################################################################
###############################################################################################
###############################################################################################


## Step 4 - Moderated Mediation Models (by partisanship of respondent) for Justify Treatment


## Moderated MEDIATION - Morals PREZ

model.m7 <- lm(morals_n ~ prejust.f * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


model.y7 <- lm(approve_n ~ prejust.f * party + morals_n * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


prezmorals_just_dem <- mediate (model.m7, model.y7,
                                treat = "prejust.f", mediator = "morals_n", covariates = list(party = "Democrat"),
                                sims= 1000, boot = TRUE)


prezmorals_just_rep <- mediate (model.m7, model.y7,
                                treat = "prejust.f", mediator = "morals_n", covariates = list(party = "Republican"),
                                sims= 1000, boot = TRUE)

summary(prezmorals_just_dem)
summary(prezmorals_just_rep)




## Moderated MEDIATION - Morals Obama


model.m8 <- lm(morals_n ~ obajust.f * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


model.y8 <- lm(approve_n ~ obajust.f * party + morals_n * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


obamorals_just_dem <- mediate (model.m8, model.y8,
                               treat = "obajust.f", mediator = "morals_n", covariates = list(party = "Democrat"),
                               sims= 1000, boot = TRUE)


obamorals_just_rep <- mediate (model.m8, model.y8,
                               treat = "obajust.f", mediator = "morals_n", covariates = list(party = "Republican"),
                               sims= 1000, boot = TRUE)

summary(obamorals_just_dem)
summary(obamorals_just_rep)




## Moderated MEDIATION - Morals Trump


model.m9 <- lm(morals_n ~ trujust.f * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


model.y9 <- lm(approve_n ~ trujust.f * party + morals_n * party + age + awareness +  
                 white.f + gender.f + edu,
               data = ac_data)


trumorals_just_dem <- mediate (model.m9, model.y9,
                               treat = "trujust.f", mediator = "morals_n", covariates = list(party = "Democrat"),
                               sims= 1000, boot = TRUE)


trumorals_just_rep <- mediate (model.m9, model.y9,
                               treat = "trujust.f", mediator = "morals_n", covariates = list(party = "Republican"),
                               sims= 1000, boot = TRUE)

summary(trumorals_just_dem)
summary(trumorals_just_rep)



## Moderated MEDIATION - Commitment PREZ

model.m10 <- lm(commit_n ~ prejust.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y10 <- lm(approve_n ~ prejust.f * party + commit_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


prezcommit_just_dem <- mediate (model.m10, model.y10,
                                treat = "prejust.f", mediator = "commit_n", covariates = list(party = "Democrat"),
                                sims= 1000, boot = TRUE)


prezcommit_just_rep <- mediate (model.m10, model.y10,
                                treat = "prejust.f", mediator = "commit_n", covariates = list(party = "Republican"),
                                sims= 1000, boot = TRUE)

summary(prezcommit_just_dem)
summary(prezcommit_just_rep)



## Moderated MEDIATION - Commitment Obama


model.m11 <- lm(commit_n ~ obajust.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y11 <- lm(approve_n ~ obajust.f * party + commit_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)



obacommit_just_dem <- mediate (model.m11, model.y11,
                               treat = "obajust.f", mediator = "commit_n", covariates = list(party = "Democrat"),
                               sims= 1000, boot = TRUE)


obacommit_just_rep <- mediate (model.m11, model.y11,
                               treat = "obajust.f", mediator = "commit_n", covariates = list(party = "Republican"),
                               sims= 1000, boot = TRUE)

summary(obacommit_just_dem)
summary(obacommit_just_rep)



## Moderated MEDIATION - Commitment Trump


model.m12 <- lm(commit_n ~ trujust.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y12 <- lm(approve_n ~ trujust.f * party + commit_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


trucommit_just_dem <- mediate (model.m12, model.y12,
                               treat = "trujust.f", mediator = "commit_n", covariates = list(party = "Democrat"),
                               sims= 1000, boot = TRUE)


trucommit_just_rep <- mediate (model.m12, model.y12,
                               treat = "trujust.f", mediator = "commit_n", covariates = list(party = "Republican"),
                               sims= 1000, boot = TRUE)

summary(trucommit_just_dem)
summary(trucommit_just_rep)


## Moderated MEDIATION - Comp PREZ

model.m19 <- lm(comp_n ~ prejust.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y19 <- lm(approve_n ~ prejust.f * party + comp_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


prezcomp_just_dem <- mediate (model.m19, model.y19,
                              treat = "prejust.f", mediator = "comp_n", covariates = list(party = "Democrat"),
                              sims= 1000, boot = TRUE)


prezcomp_just_rep <- mediate (model.m19, model.y19,
                              treat = "prejust.f", mediator = "comp_n", covariates = list(party = "Republican"),
                              sims= 1000, boot = TRUE)

summary(prezcomp_just_dem)
summary(prezcomp_just_rep)



## Moderated MEDIATION - Comp Obama


model.m20 <- lm(comp_n ~ obajust.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y20 <- lm(approve_n ~ obajust.f * party + comp_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)



obacomp_just_dem <- mediate (model.m20, model.y20,
                             treat = "obajust.f", mediator = "comp_n", covariates = list(party = "Democrat"),
                             sims= 1000, boot = TRUE)


obacomp_just_rep <- mediate (model.m20, model.y20,
                             treat = "obajust.f", mediator = "comp_n", covariates = list(party = "Republican"),
                             sims= 1000, boot = TRUE)

summary(obacomp_just_dem)
summary(obacomp_just_rep)



## Moderated MEDIATION - Comp Trump


model.m21 <- lm(comp_n ~ trujust.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y21 <- lm(approve_n ~ trujust.f * party + comp_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)



trucomp_just_dem <- mediate (model.m21, model.y21,
                             treat = "trujust.f", mediator = "comp_n", covariates = list(party = "Democrat"),
                             sims= 1000, boot = TRUE)


trucomp_just_rep <- mediate (model.m21, model.y21,
                             treat = "trujust.f", mediator = "comp_n", covariates = list(party = "Republican"),
                             sims= 1000, boot = TRUE)

summary(trucomp_just_dem)
summary(trucomp_just_rep)



## Moderated MEDIATION - Rep PREZ

model.m22 <- lm(reputation_n ~ prejust.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y22 <- lm(approve_n ~ prejust.f * party + reputation_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)



prezrep_just_dem <- mediate (model.m22, model.y22,
                             treat = "prejust.f", mediator = "reputation_n", covariates = list(party = "Democrat"),
                             sims= 1000, boot = TRUE)


prezrep_just_rep <- mediate (model.m22, model.y22,
                             treat = "prejust.f", mediator = "reputation_n", covariates = list(party = "Republican"),
                             sims= 1000, boot = TRUE)

summary(prezrep_just_dem)
summary(prezrep_just_rep)



## Moderated MEDIATION - Rep Obama


model.m23 <- lm(reputation_n ~ obajust.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y23 <- lm(approve_n ~ obajust.f * party + reputation_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


obarep_just_dem <- mediate (model.m23, model.y23,
                            treat = "obajust.f", mediator = "reputation_n", covariates = list(party = "Democrat"),
                            sims= 1000, boot = TRUE)


obarep_just_rep <- mediate (model.m23, model.y23,
                            treat = "obajust.f", mediator = "reputation_n", covariates = list(party = "Republican"),
                            sims= 1000, boot = TRUE)

summary(obarep_just_dem)
summary(obarep_just_rep)



## Moderated MEDIATION - Rep Trump


model.m24 <- lm(reputation_n ~ trujust.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y24 <- lm(approve_n ~ trujust.f * party + reputation_n * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


trurep_just_dem <- mediate (model.m24, model.y24,
                            treat = "trujust.f", mediator = "reputation_n", covariates = list(party = "Democrat"),
                            sims= 1000, boot = TRUE)


trurep_just_rep <- mediate (model.m24, model.y24,
                            treat = "trujust.f", mediator = "reputation_n", covariates = list(party = "Republican"),
                            sims= 1000, boot = TRUE)

summary(trurep_just_dem)
summary(trurep_just_rep)




##############################
##############################
##############################
##############################

## Step 5 - Run models for the Belligerence Mediation Analysis



## Moderated MEDIATION - Belligerence PREZ

model.m1b <- lm(belligerence_opp ~ back_down_prez.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y1b <- lm(approve_n ~ back_down_prez.f * party + belligerence_opp * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


prezbellig_dem <- mediate (model.m1b, model.y1b,
                           treat = "back_down_prez.f", mediator = "belligerence_opp", covariates = list(party = "Democrat"),
                           sims= 1000, boot = TRUE)


prezbellig_rep <- mediate (model.m1b, model.y1b,
                           treat = "back_down_prez.f", mediator = "belligerence_opp", covariates = list(party = "Republican"),
                           sims= 1000, boot = TRUE)

summary(prezbellig_dem)
summary(prezbellig_rep)



## Moderated MEDIATION - Belligerence Obama

model.m2b <- lm(belligerence_opp ~ back_down_obama.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y2b <- lm(approve_n ~ back_down_obama.f * party + belligerence_opp * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


obabellig_dem <- mediate (model.m2b, model.y2b,
                          treat = "back_down_obama.f", mediator = "belligerence_opp", covariates = list(party = "Democrat"),
                          sims= 1000, boot = TRUE)


obabellig_rep <- mediate (model.m2b, model.y2b,
                          treat = "back_down_obama.f", mediator = "belligerence_opp", covariates = list(party = "Republican"),
                          sims= 1000, boot = TRUE)

summary(obabellig_dem)
summary(obabellig_rep)



## Moderated MEDIATION - Belligerence Trumo

model.m3b <- lm(belligerence_opp ~ back_down_trump.f * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


model.y3b <- lm(approve_n ~ back_down_trump.f * party + belligerence_opp * party + age + awareness +  
                  white.f + gender.f + edu,
                data = ac_data)


trubellig_dem <- mediate (model.m3b, model.y3b,
                          treat = "back_down_trump.f", mediator = "belligerence_opp", covariates = list(party = "Democrat"),
                          sims= 1000, boot = TRUE)


trubellig_rep <- mediate (model.m3b, model.y3b,
                          treat = "back_down_trump.f", mediator = "belligerence_opp", covariates = list(party = "Republican"),
                          sims= 1000, boot = TRUE)

summary(trubellig_dem)
summary(trubellig_rep)





#################
################
#################
################
#################

## Step 6 - Run the Single Mediation Models for the Back Down Treatments


## Single MEDIATION - Morals PREZ

model.sm.m1 <- lm(morals_n ~ back_down_prez.f + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


model.sm.y1 <- lm(approve_n ~ back_down_prez.f + morals_n + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


prezmorals <- mediate(model.sm.m1, model.sm.y1, sims= 1000, boot = TRUE,
                      treat = "back_down_prez.f", mediator = "morals_n")

summary(prezmorals)



## Single MEDIATION - Morals Obama


model.sm.m2 <- lm(morals_n ~ back_down_obama.f + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


model.sm.y2 <- lm(approve_n ~ back_down_obama.f + morals_n + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


obamorals <- mediate (model.sm.m2, model.sm.y2, sims= 1000, boot = TRUE,
                      treat = "back_down_obama.f", mediator = "morals_n")

summary(obamorals)



## Single MEDIATION - Morals Trump


model.sm.m3 <- lm(morals_n ~ back_down_trump.f + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


model.sm.y3 <- lm(approve_n ~ back_down_trump.f + morals_n + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


trumorals <- mediate (model.sm.m3, model.sm.y3, sims= 1000, boot = TRUE,
                      treat = "back_down_trump.f", mediator = "morals_n")

summary(trumorals)


## Single MEDIATION - Commitment PREZ

model.sm.m4 <- lm(commit_n ~ back_down_prez.f + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


model.sm.y4 <- lm(approve_n ~ back_down_prez.f + commit_n + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


prezcommit <- mediate (model.sm.m4, model.sm.y4, sims= 1000, boot = TRUE,
                       treat = "back_down_prez.f", mediator = "commit_n")

summary(prezcommit)



## Single MEDIATION - Commitment Obama


model.sm.m5 <- lm(commit_n ~ back_down_obama.f + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


model.sm.y5 <- lm(approve_n ~ back_down_obama.f + commit_n + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


obacommit <- mediate (model.sm.m5, model.sm.y5, sims= 1000, boot = TRUE,
                      treat = "back_down_obama.f", mediator = "commit_n")

summary(obacommit)



## Single MEDIATION - Commitment Trump


model.sm.m6 <- lm(commit_n ~ back_down_trump.f + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


model.sm.y6 <- lm(approve_n ~ back_down_trump.f + commit_n + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


trucommit <- mediate (model.sm.m6, model.sm.y6, sims= 1000, boot = TRUE,
                      treat = "back_down_trump.f", mediator = "commit_n")

summary(trucommit)




## Single MEDIATION - Comp PREZ

model.sm.m13 <- lm(comp_n ~ back_down_prez.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y13 <- lm(approve_n ~ back_down_prez.f + comp_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


prezcomp_s <- mediate (model.sm.m13, model.sm.y13, sims= 1000, boot = TRUE,
                       treat = "back_down_prez.f", mediator = "comp_n")

summary(prezcomp_s)



## Single MEDIATION - Comp Obama


model.sm.m14 <- lm(comp_n ~ back_down_obama.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y14 <- lm(approve_n ~ back_down_obama.f + comp_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


obacomp_s <- mediate (model.sm.m14, model.sm.y14, sims= 1000, boot = TRUE,
                      treat = "back_down_obama.f", mediator = "comp_n")

summary(obacomp_s)



## Single MEDIATION - Comp Trump


model.sm.m15 <- lm(comp_n ~ back_down_trump.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y15 <- lm(approve_n ~ back_down_trump.f + comp_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


trucomp_s <- mediate (model.sm.m15, model.sm.y15, sims= 1000, boot = TRUE,
                      treat = "back_down_trump.f", mediator = "comp_n")

summary(trucomp_s)



## Single MEDIATION - Reputation PREZ

model.sm.m16 <- lm(reputation_n ~ back_down_prez.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y16 <- lm(approve_n ~ back_down_prez.f + reputation_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


prezrep_s <- mediate (model.sm.m16, model.sm.y16, sims= 1000, boot = TRUE,
                      treat = "back_down_prez.f", mediator = "reputation_n")

summary(prezrep_s)



## Single MEDIATION - Reputation Obama


model.sm.m17 <- lm(reputation_n ~ back_down_obama.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y17 <- lm(approve_n ~ back_down_obama.f + reputation_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


obarep_s <- mediate (model.sm.m17, model.sm.y17, sims= 1000, boot = TRUE,
                     treat = "back_down_obama.f", mediator = "reputation_n")

summary(obarep_s)



## Single MEDIATION - Reputation Trump


model.sm.m18 <- lm(reputation_n ~ back_down_trump.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y18 <- lm(approve_n ~ back_down_trump.f + reputation_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


trurep_s <- mediate (model.sm.m18, model.sm.y18, sims= 1000, boot = TRUE,
                     treat = "back_down_trump.f", mediator = "reputation_n")

summary(trurep_s)



###############################################################################################
###############################################################################################
###############################################################################################


## Step 7 - Run the Single Mediation Models for the Justify Treatments



## Single MEDIATION - Morals PREZ

model.sm.m7 <- lm(morals_n ~ prejust.f + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


model.sm.y7 <- lm(approve_n ~ prejust.f + morals_n + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


prezmorals_just <- mediate (model.sm.m7, model.sm.y7, sims= 1000, boot = TRUE,
                            treat = "prejust.f", mediator = "morals_n")

summary(prezmorals_just)



## Single MEDIATION - Morals Obama


model.sm.m8 <- lm(morals_n ~ obajust.f + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


model.sm.y8 <- lm(approve_n ~ obajust.f + morals_n + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


obamorals_just <- mediate (model.sm.m8, model.sm.y8, sims= 1000, boot = TRUE,
                           treat = "obajust.f", mediator = "morals_n")

summary(obamorals_just)



## Single MEDIATION - Morals Trump


model.sm.m9 <- lm(morals_n ~ trujust.f + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


model.sm.y9 <- lm(approve_n ~ trujust.f + morals_n + party + age + awareness +  
                    white.f + gender.f + edu,
                  data = ac_data)


trumorals_just <- mediate (model.sm.m9, model.sm.y9, sims= 1000, boot = TRUE,
                           treat = "trujust.f", mediator = "morals_n")

summary(trumorals_just)


## Single MEDIATION - Commitment PREZ

model.sm.m10 <- lm(commit_n ~ prejust.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y10 <- lm(approve_n ~ prejust.f + commit_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


prezcommit_just <- mediate (model.sm.m10, model.sm.y10, sims= 1000, boot = TRUE,
                            treat = "prejust.f", mediator = "commit_n")

summary(prezcommit_just)



## Single MEDIATION - Commitment Obama


model.sm.m11 <- lm(commit_n ~ obajust.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y11 <- lm(approve_n ~ obajust.f + commit_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


obacommit_just <- mediate (model.sm.m11, model.sm.y11, sims= 1000, boot = TRUE,
                           treat = "obajust.f", mediator = "commit_n")

summary(obacommit_just)



## Single MEDIATION - Commitment Trump


model.sm.m12 <- lm(commit_n ~ trujust.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y12 <- lm(approve_n ~ trujust.f + commit_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


trucommit_just <- mediate (model.sm.m12, model.sm.y12, sims= 1000, boot = TRUE,
                           treat = "trujust.f", mediator = "commit_n")

summary(trucommit_just)



## Single MEDIATION - Comp PREZ

model.sm.m19 <- lm(comp_n ~ prejust.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y19 <- lm(approve_n ~ prejust.f + comp_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


prezcomp_s1 <- mediate (model.sm.m19, model.sm.y19, sims= 1000, boot = TRUE,
                        treat = "prejust.f", mediator = "comp_n")

summary(prezcomp_s1)



## Single MEDIATION - Comp Obama


model.sm.m20 <- lm(comp_n ~ obajust.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y20 <- lm(approve_n ~ obajust.f + comp_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


obacomp_s1 <- mediate (model.sm.m20, model.sm.y20, sims= 1000, boot = TRUE,
                       treat = "obajust.f", mediator = "comp_n")

summary(obacomp_s1)



## Single MEDIATION - Comp Trump


model.sm.m21 <- lm(comp_n ~ trujust.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y21 <- lm(approve_n ~ trujust.f + comp_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


trucomp_s1 <- mediate (model.sm.m21, model.sm.y21, sims= 1000, boot = TRUE,
                       treat = "trujust.f", mediator = "comp_n")

summary(trucomp_s1)



## Single MEDIATION - Rep PREZ

model.sm.m22 <- lm(reputation_n ~ prejust.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y22 <- lm(approve_n ~ prejust.f + reputation_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


prezrep_s1 <- mediate (model.sm.m22, model.sm.y22, sims= 1000, boot = TRUE,
                       treat = "prejust.f", mediator = "reputation_n")

summary(prezrep_s1)



## Single MEDIATION - Rep Obama


model.sm.m23 <- lm(reputation_n ~ obajust.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y23 <- lm(approve_n ~ obajust.f + reputation_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


obarep_s1 <- mediate (model.sm.m23, model.sm.y23, sims= 1000, boot = TRUE,
                      treat = "obajust.f", mediator = "reputation_n")

summary(obarep_s1)



## Single MEDIATION - Rep Trump


model.sm.m24 <- lm(reputation_n ~ trujust.f + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


model.sm.y24 <- lm(approve_n ~ trujust.f + reputation_n + party + age + awareness +  
                     white.f + gender.f + edu,
                   data = ac_data)


trurep_s1 <- mediate (model.sm.m24, model.sm.y24, sims= 1000, boot = TRUE,
                      treat = "trujust.f", mediator = "reputation_n")

summary(trurep_s1)



#################
################
#################
################
#################

#################
################
################# ## Make Figures for Online Appendix
################
#################

#################
################
#################
################
#################


## Step 8 - Figure 6 - Single Causal Mediation Analysyis for the Back Down Treatment 

lims <- c(-0.22,0.15)
lims1 <- c(-1.5,0.1)

par(mfrow=c(1,2))
par(cex=0.65)
par(mar=c(5,10,5,1), oma=c(0, 0, 0, 0))


plot(0, 0, type="n", main="ADE - Back Down vs Stay Out",
     xlab = "Average Causal Mediation Effects", ylab = "",
     xlim = lims1, ylim = c(13, 29), yaxt="n")
segments(prezcomp_s$z.avg.ci[1], 28, prezcomp_s$z.avg.ci[2], 28, lwd=2)
segments(obacomp_s$z.avg.ci[1], 27, obacomp_s$z.avg.ci[2], 27, lwd=2)
segments(trucomp_s$z.avg.ci[1], 26, trucomp_s$z.avg.ci[2], 26, lwd=2)
segments(prezrep_s$z.avg.ci[1], 24, prezrep_s$z.avg.ci[2], 24, lwd=2)
segments(obarep_s$z.avg.ci[1], 23, obarep_s$z.avg.ci[2], 23, lwd=2)
segments(trurep_s$z.avg.ci[1], 22, trurep_s$z.avg.ci[2], 22, lwd=2)
segments(prezcommit$z.avg.ci[1], 20, prezcommit$z.avg.ci[2], 20, lwd=2)
segments(obacommit$z.avg.ci[1], 19, obacommit$z.avg.ci[2], 19, lwd=2)
segments(trucommit$z.avg.ci[1], 18, trucommit$z.avg.ci[2], 18, lwd=2)
segments(prezmorals$z.avg.ci[1], 16, prezmorals$z.avg.ci[2], 16, lwd=2)
segments(obamorals$z.avg.ci[1], 15, obamorals$z.avg.ci[2], 15, lwd=2)
segments(trumorals$z.avg.ci[1], 14, trumorals$z.avg.ci[2], 14, lwd=2)
points(prezcomp_s$z.avg[1], 28, pch=18, cex=2)
points(obacomp_s$z.avg[1], 27, pch=18, cex=2)
points(trucomp_s$z.avg[1], 26, pch=18, cex=2)
points(prezrep_s$z.avg[1], 24, pch=18, cex=2)
points(obarep_s$z.avg[1], 23, pch=18, cex=2) 
points(trurep_s$z.avg[1], 22, pch=18, cex=2)
points(prezcommit$z.avg[1], 20, pch=18, cex=2)
points(obacommit$z.avg[1], 19, pch=18, cex=2)
points(trucommit$z.avg[1], 18, pch=18, cex=2)
points(prezmorals$z.avg[1], 16, pch=18, cex=2)
points(obamorals$z.avg[1], 15, pch=18, cex=2)
points(trumorals$z.avg[1], 14, pch=18, cex=2)
abline(v=0)
axis(side = 2, labels = c(
  expression(paste("Pres(Competence)")),
  expression(paste("Obama(Competence)")),
  expression(paste("Trump(Competence)")),
  expression(paste("Pres(Reputation)")),
  expression(paste("Obama(Reputation)")),
  expression(paste("Trump(Reputation)")),
  expression(paste("Pres(Credibility)")),
  expression(paste("Obama(Credibility)")),
  expression(paste("Trump(Credibility)")),
  expression(paste("Pres(Morals)")),
  expression(paste("Obama(Morals)")),
  expression(paste("Trump(Morals)"))),
  at = c(28, 27, 26, 24, 23, 22, 20, 19, 18, 16, 15, 14), las = 2)

plot(0, 0, type="n", main="ACME - Back Down vs Stay Out",
     xlab = "Average Causal Mediation Effects", ylab = "",
     xlim = lims, ylim = c(13, 29), yaxt="n")
segments(prezcomp_s$d.avg.ci[1], 28, prezcomp_s$d.avg.ci[2], 28, lwd=2)
segments(obacomp_s$d.avg.ci[1], 27, obacomp_s$d.avg.ci[2], 27, lwd=2)
segments(trucomp_s$d.avg.ci[1], 26, trucomp_s$d.avg.ci[2], 26, lwd=2)
segments(prezrep_s$d.avg.ci[1], 24, prezrep_s$d.avg.ci[2], 24, lwd=2)
segments(obarep_s$d.avg.ci[1], 23, obarep_s$d.avg.ci[2], 23, lwd=2)
segments(trurep_s$d.avg.ci[1], 22, trurep_s$d.avg.ci[2], 22, lwd=2)
segments(prezcommit$d.avg.ci[1], 20, prezcommit$d.avg.ci[2], 20, lwd=2)
segments(obacommit$d.avg.ci[1], 19, obacommit$d.avg.ci[2], 19, lwd=2)
segments(trucommit$d.avg.ci[1], 18, trucommit$d.avg.ci[2], 18, lwd=2)
segments(prezmorals$d.avg.ci[1], 16, prezmorals$d.avg.ci[2], 16, lwd=2)
segments(obamorals$d.avg.ci[1], 15, obamorals$d.avg.ci[2], 15, lwd=2)
segments(trumorals$d.avg.ci[1], 14, trumorals$d.avg.ci[2], 14, lwd=2)
points(prezcomp_s$d.avg[1], 28, pch=18, cex=2)
points(obacomp_s$d.avg[1], 27, pch=18, cex=2)
points(trucomp_s$d.avg[1], 26, pch=18, cex=2)
points(prezrep_s$d.avg[1], 24, pch=18, cex=2)
points(obarep_s$d.avg[1], 23, pch=18, cex=2) 
points(trurep_s$d.avg[1], 22, pch=18, cex=2)
points(prezcommit$d.avg[1], 20, pch=18, cex=2)
points(obacommit$d.avg[1], 19, pch=18, cex=2)
points(trucommit$d.avg[1], 18, pch=18, cex=2)
points(prezmorals$d.avg[1], 16, pch=18, cex=2)
points(obamorals$d.avg[1], 15, pch=18, cex=2)
points(trumorals$d.avg[1], 14, pch=18, cex=2)
abline(v=0)
axis(side = 2, labels = c(
  expression(paste("Pres(Competence)")),
  expression(paste("Obama(Competence)")),
  expression(paste("Trump(Competence)")),
  expression(paste("Pres(Reputation)")),
  expression(paste("Obama(Reputation)")),
  expression(paste("Trump(Reputation)")),
  expression(paste("Pres(Credibility)")),
  expression(paste("Obama(Credibility)")),
  expression(paste("Trump(Credibility)")),
  expression(paste("Pres(Morals)")),
  expression(paste("Obama(Morals)")),
  expression(paste("Trump(Morals)"))),
  at = c(28, 27, 26, 24, 23, 22, 20, 19, 18, 16, 15, 14), las = 2)


dev.off()


##
##
## Step 9 - Figure 7 - Single Causal Mediation Analysyis for the Justify Treatment 
##
##

lims <- c(-0.1,0.25)
lims1 <- c(-0.1,1.5)

par(mfrow=c(1,2))
par(cex=0.65)
par(mar=c(5,10,5,1), oma=c(0, 0, 0, 0))


plot(0, 0, type="n", main="ADE - Justify vs Back Down",
     xlab = "Average Causal Mediation Effects", ylab = "",
     xlim = lims1, ylim = c(13, 29), yaxt="n")
segments(prezcomp_s1$z.avg.ci[1], 28, prezcomp_s1$z.avg.ci[2], 28, lwd=2)
segments(obacomp_s1$z.avg.ci[1], 27, obacomp_s1$z.avg.ci[2], 27, lwd=2)
segments(trucomp_s1$z.avg.ci[1], 26, trucomp_s1$z.avg.ci[2], 26, lwd=2)
segments(prezrep_s1$z.avg.ci[1], 24, prezrep_s1$z.avg.ci[2], 24, lwd=2)
segments(obarep_s1$z.avg.ci[1], 23, obarep_s1$z.avg.ci[2], 23, lwd=2)
segments(trurep_s1$z.avg.ci[1], 22, trurep_s1$z.avg.ci[2], 22, lwd=2)
segments(prezcommit_just$z.avg.ci[1], 20, prezcommit_just$z.avg.ci[2], 20, lwd=2)
segments(obacommit_just$z.avg.ci[1], 19, obacommit_just$z.avg.ci[2], 19, lwd=2)
segments(trucommit_just$z.avg.ci[1], 18, trucommit_just$z.avg.ci[2], 18, lwd=2)
segments(prezmorals_just$z.avg.ci[1], 16, prezmorals_just$z.avg.ci[2], 16, lwd=2)
segments(obamorals_just$z.avg.ci[1], 15, obamorals_just$z.avg.ci[2], 15, lwd=2)
segments(trumorals_just$z.avg.ci[1], 14, trumorals_just$z.avg.ci[2], 14, lwd=2)
points(prezcomp_s1$z.avg[1], 28, pch=18, cex=2)
points(obacomp_s1$z.avg[1], 27, pch=18, cex=2)
points(trucomp_s1$z.avg[1], 26, pch=18, cex=2)
points(prezrep_s1$z.avg[1], 24, pch=18, cex=2)
points(obarep_s1$z.avg[1], 23, pch=18, cex=2)
points(trurep_s1$z.avg[1], 22, pch=18, cex=2)
points(prezcommit_just$z.avg[1], 20, pch=18, cex=2)
points(obacommit_just$z.avg[1], 19, pch=18, cex=2)
points(trucommit_just$z.avg[1], 18, pch=18, cex=2)
points(prezmorals_just$z.avg[1], 16, pch=18, cex=2)
points(obamorals_just$z.avg[1], 15, pch=18, cex=2)
points(trumorals_just$z.avg[1], 14, pch=18, cex=2)
abline(v=0)
axis(side = 2, labels = c(
  expression(paste("Pres(Competence)")),
  expression(paste("Obama(Competence)")),
  expression(paste("Trump(Competence)")),
  expression(paste("Pres(Reputation)")),
  expression(paste("Obama(Reputation)")),
  expression(paste("Trump(Reputation)")),
  expression(paste("Pres(Credibility)")),
  expression(paste("Obama(Credibility)")),
  expression(paste("Trump(Credibility)")),
  expression(paste("Pres(Morals)")),
  expression(paste("Obama(Morals)")),
  expression(paste("Trump(Morals)"))),
  at = c(28, 27, 26, 24, 23, 22, 20, 19, 18, 16, 15, 14), las = 2)

plot(0, 0, type="n", main="ACME - Justify vs Back Down",
     xlab = "Average Causal Mediation Effects", ylab = "",
     xlim = lims, ylim = c(13, 29), yaxt="n")
segments(prezcomp_s1$d.avg.ci[1], 28, prezcomp_s1$d.avg.ci[2], 28, lwd=2)
segments(obacomp_s1$d.avg.ci[1], 27, obacomp_s1$d.avg.ci[2], 27, lwd=2)
segments(trucomp_s1$d.avg.ci[1], 26, trucomp_s1$d.avg.ci[2], 26, lwd=2)
segments(prezrep_s1$d.avg.ci[1], 24, prezrep_s1$d.avg.ci[2], 24, lwd=2)
segments(obarep_s1$d.avg.ci[1], 23, obarep_s1$d.avg.ci[2], 23, lwd=2)
segments(trurep_s1$d.avg.ci[1], 22, trurep_s1$d.avg.ci[2], 22, lwd=2)
segments(prezcommit_just$d.avg.ci[1], 20, prezcommit_just$d.avg.ci[2], 20, lwd=2)
segments(obacommit_just$d.avg.ci[1], 19, obacommit_just$d.avg.ci[2], 19, lwd=2)
segments(trucommit_just$d.avg.ci[1], 18, trucommit_just$d.avg.ci[2], 18, lwd=2)
segments(prezmorals_just$d.avg.ci[1], 16, prezmorals_just$d.avg.ci[2], 16, lwd=2)
segments(obamorals_just$d.avg.ci[1], 15, obamorals_just$d.avg.ci[2], 15, lwd=2)
segments(trumorals_just$d.avg.ci[1], 14, trumorals_just$d.avg.ci[2], 14, lwd=2)
points(prezcomp_s1$d.avg[1], 28, pch=18, cex=2)
points(obacomp_s1$d.avg[1], 27, pch=18, cex=2)
points(trucomp_s1$d.avg[1], 26, pch=18, cex=2)
points(prezrep_s1$d.avg[1], 24, pch=18, cex=2)
points(obarep_s1$d.avg[1], 23, pch=18, cex=2)
points(trurep_s1$d.avg[1], 22, pch=18, cex=2)
points(prezcommit_just$d.avg[1], 20, pch=18, cex=2)
points(obacommit_just$d.avg[1], 19, pch=18, cex=2)
points(trucommit_just$d.avg[1], 18, pch=18, cex=2)
points(prezmorals_just$d.avg[1], 16, pch=18, cex=2)
points(obamorals_just$d.avg[1], 15, pch=18, cex=2)
points(trumorals_just$d.avg[1], 14, pch=18, cex=2)
abline(v=0)
axis(side = 2, labels = c(
  expression(paste("Pres(Competence)")),
  expression(paste("Obama(Competence)")),
  expression(paste("Trump(Competence)")),
  expression(paste("Pres(Reputation)")),
  expression(paste("Obama(Reputation)")),
  expression(paste("Trump(Reputation)")),
  expression(paste("Pres(Credibility)")),
  expression(paste("Obama(Credibility)")),
  expression(paste("Trump(Credibility)")),
  expression(paste("Pres(Morals)")),
  expression(paste("Obama(Morals)")),
  expression(paste("Trump(Morals)"))),
  at = c(28, 27, 26, 24, 23, 22, 20, 19, 18, 16, 15, 14), las = 2)


dev.off()


## Step 10 - Figure 8 - Moderated Causal Mediation Analysyis for the Back Down Treatment 
##
## In the appendix, Fig 8 combines both [A] and [B] below


# [A] # Competence and Morality Graphs (Back Down)

lims <- c(-0.35,0.2)
lims1 <- c(-1.5,0.1)

par(mfrow=c(2,2))
par(cex=0.65)
par(mar=c(2.3,7,5,1), oma=c(0, 0, 0, 0))


plot(0, 0, type="n", main="ADE Competence (Back Down vs Stay Out)",
     xlab = "", ylab = "",
     xlim = lims1, ylim = c(0, 37), yaxt="n")
segments(prezcomp_dem$z.avg.ci[1], 36, prezcomp_dem$z.avg.ci[2], 36, lwd=2)
segments(prezcomp_rep$z.avg.ci[1], 31, prezcomp_rep$z.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obacomp_dem$z.avg.ci[1], 21, obacomp_dem$z.avg.ci[2], 21, lwd=2)
segments(obacomp_rep$z.avg.ci[1], 16, obacomp_rep$z.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trucomp_dem$z.avg.ci[1], 6, trucomp_dem$z.avg.ci[2], 6, lwd=2)
segments(trucomp_rep$z.avg.ci[1], 1, trucomp_rep$z.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezcomp_dem$z.avg[1], 36, pch=18, cex=2)
points(prezcomp_rep$z.avg[1], 31, pch=18, cex=2)
points(obacomp_dem$z.avg[1], 21, pch=18, cex=2)
points(obacomp_rep$z.avg[1], 16, pch=18, cex=2)
points(trucomp_dem$z.avg[1], 6, pch=18, cex=2)
points(trucomp_rep$z.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ACME Competence (Back Down vs Stay Out)",
     xlab = "", ylab = "",
     xlim = lims, ylim = c(0, 37), yaxt="n")
segments(prezcomp_dem$d.avg.ci[1], 36, prezcomp_dem$d.avg.ci[2], 36, lwd=2)
segments(prezcomp_rep$d.avg.ci[1], 31, prezcomp_rep$d.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obacomp_dem$d.avg.ci[1], 21, obacomp_dem$d.avg.ci[2], 21, lwd=2)
segments(obacomp_rep$d.avg.ci[1], 16, obacomp_rep$d.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trucomp_dem$d.avg.ci[1], 6, trucomp_dem$d.avg.ci[2], 6, lwd=2)
segments(trucomp_rep$d.avg.ci[1], 1, trucomp_rep$d.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezcomp_dem$d.avg[1], 36, pch=18, cex=2)
points(prezcomp_rep$d.avg[1], 31, pch=18, cex=2)
points(obacomp_dem$d.avg[1], 21, pch=18, cex=2)
points(obacomp_rep$d.avg[1], 16, pch=18, cex=2)
points(trucomp_dem$d.avg[1], 6, pch=18, cex=2)
points(trucomp_rep$d.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ADE Morals (Back Down vs Stay Out)",
     xlab = "", ylab = "",
     xlim = lims1, ylim = c(0, 37), yaxt="n")
segments(prezmorals_dem$z.avg.ci[1], 36, prezmorals_dem$z.avg.ci[2], 36, lwd=2)
segments(prezmorals_rep$z.avg.ci[1], 31, prezmorals_rep$z.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obamorals_dem$z.avg.ci[1], 21, obamorals_dem$z.avg.ci[2], 21, lwd=2)
segments(obamorals_rep$z.avg.ci[1], 16, obamorals_rep$z.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trumorals_dem$z.avg.ci[1], 6, trumorals_dem$z.avg.ci[2], 6, lwd=2)
segments(trumorals_rep$z.avg.ci[1], 1, trumorals_rep$z.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezmorals_dem$z.avg[1], 36, pch=18, cex=2)
points(prezmorals_rep$z.avg[1], 31, pch=18, cex=2)
points(obamorals_dem$z.avg[1], 21, pch=18, cex=2)
points(obamorals_rep$z.avg[1], 16, pch=18, cex=2)
points(trumorals_dem$z.avg[1], 6, pch=18, cex=2)
points(trumorals_rep$z.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ACME Morals (Back Down vs Stay Out)",
     xlab = "", ylab = "",
     xlim = lims, ylim = c(0, 37), yaxt="n")
segments(prezmorals_dem$d.avg.ci[1], 36, prezmorals_dem$d.avg.ci[2], 36, lwd=2)
segments(prezmorals_rep$d.avg.ci[1], 31, prezmorals_rep$d.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obamorals_dem$d.avg.ci[1], 21, obamorals_dem$d.avg.ci[2], 21, lwd=2)
segments(obamorals_rep$d.avg.ci[1], 16, obamorals_rep$d.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trumorals_dem$d.avg.ci[1], 6, trumorals_dem$d.avg.ci[2], 6, lwd=2)
segments(trumorals_rep$d.avg.ci[1], 1, trumorals_rep$d.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezmorals_dem$d.avg[1], 36, pch=18, cex=2)
points(prezmorals_rep$d.avg[1], 31, pch=18, cex=2)
points(obamorals_dem$d.avg[1], 21, pch=18, cex=2)
points(obamorals_rep$d.avg[1], 16, pch=18, cex=2)
points(trumorals_dem$d.avg[1], 6, pch=18, cex=2)
points(trumorals_rep$d.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

dev.off()


# [B] # Reputation and Commitment (Titled Credibility) Graphs (Back Down)

lims <- c(-0.31,0.17)
lims1 <- c(-1.55,0.05)

par(mfrow=c(2,2))
par(cex=0.65)
par(mar=c(2.3,7,5,1), oma=c(0, 0, 0, 0))


plot(0, 0, type="n", main="ADE Reputation (Back Down vs Stay Out)",
     xlab = "", ylab = "",
     xlim = lims1, ylim = c(0, 37), yaxt="n")
segments(prezrep_dem$z.avg.ci[1], 36, prezrep_dem$z.avg.ci[2], 36, lwd=2)
segments(prezrep_rep$z.avg.ci[1], 31, prezrep_rep$z.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obarep_dem$z.avg.ci[1], 21, obarep_dem$z.avg.ci[2], 21, lwd=2)
segments(obarep_rep$z.avg.ci[1], 16, obarep_rep$z.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trurep_dem$z.avg.ci[1], 6, trurep_dem$z.avg.ci[2], 6, lwd=2)
segments(trurep_rep$z.avg.ci[1], 1, trurep_rep$z.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezrep_dem$z.avg[1], 36, pch=18, cex=2)
points(prezrep_rep$z.avg[1], 31, pch=18, cex=2)
points(obarep_dem$z.avg[1], 21, pch=18, cex=2)
points(obarep_rep$z.avg[1], 16, pch=18, cex=2)
points(trurep_dem$z.avg[1], 6, pch=18, cex=2)
points(trurep_rep$z.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ACME Reputation (Back Down vs Stay Out)",
     xlab = "", ylab = "",
     xlim = lims, ylim = c(0, 37), yaxt="n")
segments(prezrep_dem$d.avg.ci[1], 36, prezrep_dem$d.avg.ci[2], 36, lwd=2)
segments(prezrep_rep$d.avg.ci[1], 31, prezrep_rep$d.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obarep_dem$d.avg.ci[1], 21, obarep_dem$d.avg.ci[2], 21, lwd=2)
segments(obarep_rep$d.avg.ci[1], 16, obarep_rep$d.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trurep_dem$d.avg.ci[1], 6, trurep_dem$d.avg.ci[2], 6, lwd=2)
segments(trurep_rep$d.avg.ci[1], 1, trurep_rep$d.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezrep_dem$d.avg[1], 36, pch=18, cex=2)
points(prezrep_rep$d.avg[1], 31, pch=18, cex=2)
points(obarep_dem$d.avg[1], 21, pch=18, cex=2)
points(obarep_rep$d.avg[1], 16, pch=18, cex=2)
points(trurep_dem$d.avg[1], 6, pch=18, cex=2)
points(trurep_rep$d.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ADE Credibility (Back Down vs Stay Out)",
     xlab = "", ylab = "",
     xlim = lims1, ylim = c(0, 37), yaxt="n")
segments(prezcommit_dem$z.avg.ci[1], 36, prezcommit_dem$z.avg.ci[2], 36, lwd=2, lty = 'dashed')
segments(prezcommit_rep$z.avg.ci[1], 31, prezcommit_rep$z.avg.ci[2], 31, lwd=2)
segments(obacommit_dem$z.avg.ci[1], 21, obacommit_dem$z.avg.ci[2], 21, lwd=2, lty = 'dashed')
segments(obacommit_rep$z.avg.ci[1], 16, obacommit_rep$z.avg.ci[2], 16, lwd=2)
segments(trucommit_dem$z.avg.ci[1], 6, trucommit_dem$z.avg.ci[2], 6, lwd=2, lty = 'dashed')
segments(trucommit_rep$z.avg.ci[1], 1, trucommit_rep$z.avg.ci[2], 1, lwd=2)
points(prezcommit_dem$z.avg[1], 36, pch=18, cex=2)
points(prezcommit_rep$z.avg[1], 31, pch=18, cex=2)
points(obacommit_dem$z.avg[1], 21, pch=18, cex=2)
points(obacommit_rep$z.avg[1], 16, pch=18, cex=2)
points(trucommit_dem$z.avg[1], 6, pch=18, cex=2)
points(trucommit_rep$z.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ACME Credibility (Back Down vs Stay Out)",
     xlab = "", ylab = "",
     xlim = lims, ylim = c(0, 37), yaxt="n")
segments(prezcommit_dem$d.avg.ci[1], 36, prezcommit_dem$d.avg.ci[2], 36, lwd=2)
segments(prezcommit_rep$d.avg.ci[1], 31, prezcommit_rep$d.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obacommit_dem$d.avg.ci[1], 21, obacommit_dem$d.avg.ci[2], 21, lwd=2)
segments(obacommit_rep$d.avg.ci[1], 16, obacommit_rep$d.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trucommit_dem$d.avg.ci[1], 6, trucommit_dem$d.avg.ci[2], 6, lwd=2)
segments(trucommit_rep$d.avg.ci[1], 1, trucommit_rep$d.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezcommit_dem$d.avg[1], 36, pch=18, cex=2)
points(prezcommit_rep$d.avg[1], 31, pch=18, cex=2)
points(obacommit_dem$d.avg[1], 21, pch=18, cex=2)
points(obacommit_rep$d.avg[1], 16, pch=18, cex=2)
points(trucommit_dem$d.avg[1], 6, pch=18, cex=2)
points(trucommit_rep$d.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

dev.off()




## Step 11 - Figure 9 - Moderated Causal Mediation Analysyis for the Justify Treatment 
##
## In the appendix, Fig 9 combines both [A] and [B] below


# [A] # Competence and Morality Graphs (Justify)

lims <- c(-0.1,0.6)
lims1 <- c(-0.1,1.6)

par(mfrow=c(2,2))
par(cex=0.65)
par(mar=c(2.3,7,5,1), oma=c(0, 0, 0, 0))


plot(0, 0, type="n", main="ADE Competence (Justify vs Back Down)",
     xlab = "", ylab = "",
     xlim = lims1, ylim = c(0, 37), yaxt="n")
segments(prezcomp_just_dem$z.avg.ci[1], 36, prezcomp_just_dem$z.avg.ci[2], 36, lwd=2)
segments(prezcomp_just_rep$z.avg.ci[1], 31, prezcomp_just_rep$z.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obacomp_just_dem$z.avg.ci[1], 21, obacomp_just_dem$z.avg.ci[2], 21, lwd=2)
segments(obacomp_just_rep$z.avg.ci[1], 16, obacomp_just_rep$z.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trucomp_just_dem$z.avg.ci[1], 6, trucomp_just_dem$z.avg.ci[2], 6, lwd=2)
segments(trucomp_just_rep$z.avg.ci[1], 1, trucomp_just_rep$z.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezcomp_just_dem$z.avg[1], 36, pch=18, cex=2)
points(prezcomp_just_rep$z.avg[1], 31, pch=18, cex=2)
points(obacomp_just_dem$z.avg[1], 21, pch=18, cex=2)
points(obacomp_just_rep$z.avg[1], 16, pch=18, cex=2)
points(trucomp_just_dem$z.avg[1], 6, pch=18, cex=2)
points(trucomp_just_rep$z.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ACME Competence (Justify vs Back Down)",
     xlab = "", ylab = "",
     xlim = lims, ylim = c(0, 37), yaxt="n")
segments(prezcomp_just_dem$d.avg.ci[1], 36, prezcomp_just_dem$d.avg.ci[2], 36, lwd=2)
segments(prezcomp_just_rep$d.avg.ci[1], 31, prezcomp_just_rep$d.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obacomp_just_dem$d.avg.ci[1], 21, obacomp_just_dem$d.avg.ci[2], 21, lwd=2)
segments(obacomp_just_rep$d.avg.ci[1], 16, obacomp_just_rep$d.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trucomp_just_dem$d.avg.ci[1], 6, trucomp_just_dem$d.avg.ci[2], 6, lwd=2)
segments(trucomp_just_rep$d.avg.ci[1], 1, trucomp_just_rep$d.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezcomp_just_dem$d.avg[1], 36, pch=18, cex=2)
points(prezcomp_just_rep$d.avg[1], 31, pch=18, cex=2)
points(obacomp_just_dem$d.avg[1], 21, pch=18, cex=2)
points(obacomp_just_rep$d.avg[1], 16, pch=18, cex=2)
points(trucomp_just_dem$d.avg[1], 6, pch=18, cex=2)
points(trucomp_just_rep$d.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ADE Morals (Justify vs Back Down)",
     xlab = "", ylab = "",
     xlim = lims1, ylim = c(0, 37), yaxt="n")
segments(prezmorals_just_dem$z.avg.ci[1], 36, prezmorals_just_dem$z.avg.ci[2], 36, lwd=2)
segments(prezmorals_just_rep$z.avg.ci[1], 31, prezmorals_just_rep$z.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obamorals_just_dem$z.avg.ci[1], 21, obamorals_just_dem$z.avg.ci[2], 21, lwd=2)
segments(obamorals_just_rep$z.avg.ci[1], 16, obamorals_just_rep$z.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trumorals_just_dem$z.avg.ci[1], 6, trumorals_just_dem$z.avg.ci[2], 6, lwd=2)
segments(trumorals_just_rep$z.avg.ci[1], 1, trumorals_just_rep$z.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezmorals_just_dem$z.avg[1], 36, pch=18, cex=2)
points(prezmorals_just_rep$z.avg[1], 31, pch=18, cex=2)
points(obamorals_just_dem$z.avg[1], 21, pch=18, cex=2)
points(obamorals_just_rep$z.avg[1], 16, pch=18, cex=2)
points(trumorals_just_dem$z.avg[1], 6, pch=18, cex=2)
points(trumorals_just_rep$z.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ACME Morals (Back Down vs Stay Out)",
     xlab = "", ylab = "",
     xlim = lims, ylim = c(0, 37), yaxt="n")
segments(prezmorals_just_dem$d.avg.ci[1], 36, prezmorals_just_dem$d.avg.ci[2], 36, lwd=2)
segments(prezmorals_just_rep$d.avg.ci[1], 31, prezmorals_just_rep$d.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obamorals_just_dem$d.avg.ci[1], 21, obamorals_just_dem$d.avg.ci[2], 21, lwd=2)
segments(obamorals_just_rep$d.avg.ci[1], 16, obamorals_just_rep$d.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trumorals_just_dem$d.avg.ci[1], 6, trumorals_just_dem$d.avg.ci[2], 6, lwd=2)
segments(trumorals_just_rep$d.avg.ci[1], 1, trumorals_just_rep$d.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezmorals_just_dem$d.avg[1], 36, pch=18, cex=2)
points(prezmorals_just_rep$d.avg[1], 31, pch=18, cex=2)
points(obamorals_just_dem$d.avg[1], 21, pch=18, cex=2)
points(obamorals_just_rep$d.avg[1], 16, pch=18, cex=2)
points(trumorals_just_dem$d.avg[1], 6, pch=18, cex=2)
points(trumorals_just_rep$d.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

dev.off()


# [B] # Reputation and Commitment (Titled Credibility) Graphs (Back Down)

lims <- c(-0.25,0.22)
lims1 <- c(-0.1,1.6)


par(mfrow=c(2,2))
par(cex=0.65)
par(mar=c(2.3,7,5,1), oma=c(0, 0, 0, 0))


plot(0, 0, type="n", main="ADE Reputation (Justify vs Back Down)",
     xlab = "", ylab = "",
     xlim = lims1, ylim = c(0, 37), yaxt="n")
segments(prezrep_just_dem$z.avg.ci[1], 36, prezrep_just_dem$z.avg.ci[2], 36, lwd=2)
segments(prezrep_just_rep$z.avg.ci[1], 31, prezrep_just_rep$z.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obarep_just_dem$z.avg.ci[1], 21, obarep_just_dem$z.avg.ci[2], 21, lwd=2)
segments(obarep_just_rep$z.avg.ci[1], 16, obarep_just_rep$z.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trurep_just_dem$z.avg.ci[1], 6, trurep_just_dem$z.avg.ci[2], 6, lwd=2)
segments(trurep_just_rep$z.avg.ci[1], 1, trurep_just_rep$z.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezrep_just_dem$z.avg[1], 36, pch=18, cex=2)
points(prezrep_just_rep$z.avg[1], 31, pch=18, cex=2)
points(obarep_just_dem$z.avg[1], 21, pch=18, cex=2)
points(obarep_just_rep$z.avg[1], 16, pch=18, cex=2)
points(trurep_just_dem$z.avg[1], 6, pch=18, cex=2)
points(trurep_just_rep$z.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ACME Reputation (Justify vs Back Down)",
     xlab = "", ylab = "",
     xlim = lims, ylim = c(0, 37), yaxt="n")
segments(prezrep_just_dem$d.avg.ci[1], 36, prezrep_just_dem$d.avg.ci[2], 36, lwd=2)
segments(prezrep_just_rep$d.avg.ci[1], 31, prezrep_just_rep$d.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obarep_just_dem$d.avg.ci[1], 21, obarep_just_dem$d.avg.ci[2], 21, lwd=2)
segments(obarep_just_rep$d.avg.ci[1], 16, obarep_just_rep$d.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trurep_just_dem$d.avg.ci[1], 6, trurep_just_dem$d.avg.ci[2], 6, lwd=2)
segments(trurep_just_rep$d.avg.ci[1], 1, trurep_just_rep$d.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezrep_just_dem$d.avg[1], 36, pch=18, cex=2)
points(prezrep_just_rep$d.avg[1], 31, pch=18, cex=2)
points(obarep_just_dem$d.avg[1], 21, pch=18, cex=2)
points(obarep_just_rep$d.avg[1], 16, pch=18, cex=2)
points(trurep_just_dem$d.avg[1], 6, pch=18, cex=2)
points(trurep_just_rep$d.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ADE Credibility (Justify vs Back Down)",
     xlab = "", ylab = "",
     xlim = lims1, ylim = c(0, 37), yaxt="n")
segments(prezcommit_just_dem$z.avg.ci[1], 36, prezcommit_just_dem$z.avg.ci[2], 36, lwd=2, lty = 'dashed')
segments(prezcommit_just_rep$z.avg.ci[1], 31, prezcommit_just_rep$z.avg.ci[2], 31, lwd=2)
segments(obacommit_just_dem$z.avg.ci[1], 21, obacommit_just_dem$z.avg.ci[2], 21, lwd=2, lty = 'dashed')
segments(obacommit_just_rep$z.avg.ci[1], 16, obacommit_just_rep$z.avg.ci[2], 16, lwd=2)
segments(trucommit_just_dem$z.avg.ci[1], 6, trucommit_just_dem$z.avg.ci[2], 6, lwd=2, lty = 'dashed')
segments(trucommit_just_rep$z.avg.ci[1], 1, trucommit_just_rep$z.avg.ci[2], 1, lwd=2)
points(prezcommit_just_dem$z.avg[1], 36, pch=18, cex=2)
points(prezcommit_just_rep$z.avg[1], 31, pch=18, cex=2)
points(obacommit_just_dem$z.avg[1], 21, pch=18, cex=2)
points(obacommit_just_rep$z.avg[1], 16, pch=18, cex=2)
points(trucommit_just_dem$z.avg[1], 6, pch=18, cex=2)
points(trucommit_just_rep$z.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

plot(0, 0, type="n", main="ACME Credibility (Justify vs Back Down)",
     xlab = "", ylab = "",
     xlim = lims, ylim = c(0, 37), yaxt="n")
segments(prezcommit_just_dem$d.avg.ci[1], 36, prezcommit_just_dem$d.avg.ci[2], 36, lwd=2)
segments(prezcommit_just_rep$d.avg.ci[1], 31, prezcommit_just_rep$d.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(obacommit_just_dem$d.avg.ci[1], 21, obacommit_just_dem$d.avg.ci[2], 21, lwd=2)
segments(obacommit_just_rep$d.avg.ci[1], 16, obacommit_just_rep$d.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trucommit_just_dem$d.avg.ci[1], 6, trucommit_just_dem$d.avg.ci[2], 6, lwd=2)
segments(trucommit_just_rep$d.avg.ci[1], 1, trucommit_just_rep$d.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezcommit_just_dem$d.avg[1], 36, pch=18, cex=2)
points(prezcommit_just_rep$d.avg[1], 31, pch=18, cex=2)
points(obacommit_just_dem$d.avg[1], 21, pch=18, cex=2)
points(obacommit_just_rep$d.avg[1], 16, pch=18, cex=2)
points(trucommit_just_dem$d.avg[1], 6, pch=18, cex=2)
points(trucommit_just_rep$d.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=0.8, labels = c(
  expression(paste("Pres(Dem)")),
  expression(paste("Pres(Repub)")),
  expression(paste("Obama(Dem)")),
  expression(paste("Obama(Repub)")),
  expression(paste("Trump(Dem)")),
  expression(paste("Trump(Repub)"))),
  at = c(36, 31, 21, 16, 6, 1), las = 2) 

dev.off()


##
##
## Step 12 - Figure 10 - Moderated Causal Mediation Analysyis for Belligerence (Back Down Treatment Only)
##
##

lims <- c(-0.31,0.17)
lims1 <- c(-1.4,0.5)

par(mfrow=c(1,1))
par(cex=0.65)
par(mar=c(2.3,10,5,1), oma=c(0, 0, 0, 0))


plot(0, 0, type="n", main="Mediation Effects: Belligerence (Back Down vs Stay Out)",
     xlab = "", ylab = "",
     xlim = lims1, ylim = c(0, 80), yaxt="n")
segments(prezbellig_dem$d.avg.ci[1], 79, prezbellig_dem$d.avg.ci[2], 79, lwd=2)
segments(prezbellig_dem$z.avg.ci[1], 76, prezbellig_dem$z.avg.ci[2], 76, lwd=2, lty = 'dashed')
segments(prezbellig_rep$d.avg.ci[1], 64, prezbellig_rep$d.avg.ci[2], 64, lwd=2)
segments(prezbellig_rep$z.avg.ci[1], 61, prezbellig_rep$z.avg.ci[2], 61, lwd=2, lty = 'dashed')
segments(obabellig_dem$d.avg.ci[1], 49, obabellig_dem$d.avg.ci[2], 49, lwd=2)
segments(obabellig_dem$z.avg.ci[1], 46, obabellig_dem$z.avg.ci[2], 46, lwd=2, lty = 'dashed')
segments(obabellig_rep$d.avg.ci[1], 34, obabellig_rep$d.avg.ci[2], 34, lwd=2)
segments(obabellig_rep$z.avg.ci[1], 31, obabellig_rep$z.avg.ci[2], 31, lwd=2, lty = 'dashed')
segments(trubellig_dem$d.avg.ci[1], 19, trubellig_dem$d.avg.ci[2], 19, lwd=2)
segments(trubellig_dem$z.avg.ci[1], 16, trubellig_dem$z.avg.ci[2], 16, lwd=2, lty = 'dashed')
segments(trubellig_rep$d.avg.ci[1], 4, trubellig_rep$d.avg.ci[2], 4, lwd=2)
segments(trubellig_rep$z.avg.ci[1], 1, trubellig_rep$z.avg.ci[2], 1, lwd=2, lty = 'dashed')
points(prezbellig_dem$d.avg[1], 79, pch=18, cex=2)
points(prezbellig_dem$z.avg[1], 76, pch=18, cex=2)
points(prezbellig_rep$d.avg[1], 64, pch=18, cex=2)
points(prezbellig_rep$z.avg[1], 61, pch=18, cex=2)
points(obabellig_dem$d.avg[1], 49, pch=18, cex=2)
points(obabellig_dem$z.avg[1], 46, pch=18, cex=2)
points(obabellig_rep$d.avg[1], 34, pch=18, cex=2)
points(obabellig_rep$z.avg[1], 31, pch=18, cex=2)
points(trubellig_dem$d.avg[1], 19, pch=18, cex=2)
points(trubellig_dem$z.avg[1], 16, pch=18, cex=2)
points(trubellig_rep$d.avg[1], 4, pch=18, cex=2)
points(trubellig_rep$z.avg[1], 1, pch=18, cex=2)
abline(v=0)
axis(side = 2, cex.lab=3, labels = c(
  expression(paste("ACME - Pres(Dem)")),
  expression(paste("ADE - Pres(Dem)")),
  expression(paste("ACME - Pres(Repub)")),
  expression(paste("ADE - Pres(Repub)")),
  expression(paste("ACME - Obama(Dem)")),
  expression(paste("ADE - Obama(Dem)")),
  expression(paste("ACME - Obama(Repub)")),
  expression(paste("ADE - Obama(Repub)")),
  expression(paste("ACME - Trump(Dem)")),
  expression(paste("ADE - Trump(Dem)")),
  expression(paste("ACME - Trump(Repub)")),
  expression(paste("ADE - Trump(Repub)"))),
  at = c(79, 76, 64, 61, 49, 46, 34, 31, 19, 16, 4, 1), las = 2) 

dev.off()


